package main;

import java.io.File;
import java.io.IOException;

import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.apache.log4j.Logger;

import app.action.AppUtilities;
import app.ui.MainFrame;

public class MyServer {
	private static String className = MyServer.class.getName();
	private static String currentPath = System.getProperty("user.dir") + "/";

	private final static Logger logger = Logger.getLogger(MyServer.class);

	public static void main(String[] args) {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}catch (ClassNotFoundException e) {
			logger.error(e.getMessage(), e.getCause());
		}catch (InstantiationException e) {
			logger.error(e.getMessage(), e.getCause());
		}catch (IllegalAccessException e) {
			logger.error(e.getMessage(), e.getCause());
		}catch (UnsupportedLookAndFeelException e) {
			logger.error(e.getMessage(), e.getCause());
		}

		MainFrame mainFrame;
		try {
			mainFrame = new MainFrame(getAppUtilities());
			mainFrame.setVisible(true);
		}catch (IOException e) {
			logger.error(e.getMessage(), e.getCause());
		}
	}

	private static AppUtilities getAppUtilities() throws IOException {
		AppUtilities appUtilities = null;
		File file = new File(currentPath + className + ".ini");
		appUtilities = new AppUtilities(file);

		return appUtilities;
	}
}
